<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>遍历数组</title>
    <script>
        //遍历数组:就是把数组的元素从头到尾访问一次
        var arr = ['red', 'green', 'blue'];
        for (var i = 0; i < 3; i++) {
            console.log(arr[i]);
        }
        //1.因为我们的数组索引号从0开始,所以i必须从0开始 i<3
        //2.输出的时候 arr[i]  i 计数器当索引号来用

        //课堂案例:
        //请将['关羽','张飞','马超','赵云','黄忠','刘备','姜维'];数组里的袁术依次打印到控制台
        var arr3 = ['关羽', '张飞', '马超', '赵云', '黄忠', '刘备', '姜维'];
        for (var j = 0; j < 7; j++) {
            console.log(arr3[j]);
        }
    </script>
</head>

<body>

</body>

</html>